package com.ruoyi.web.controller.system;

import java.util.List;
import javax.servlet.http.HttpServletResponse;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.ruoyi.common.annotation.Log;
import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.enums.BusinessType;
import com.ruoyi.system.domain.LuntaiUserTyre;
import com.ruoyi.system.service.ILuntaiUserTyreService;
import com.ruoyi.common.utils.poi.ExcelUtil;
import com.ruoyi.common.core.page.TableDataInfo;

/**
 * tyre 用户轮胎信息Controller
 * 
 * @author ruoyi
 * @date 2025-02-17
 */
@RestController
@RequestMapping("/system/userTyre")
public class LuntaiUserTyreController extends BaseController
{
    @Autowired
    private ILuntaiUserTyreService luntaiUserTyreService;

    /**
     * 查询tyre 用户轮胎信息列表
     */
    @PreAuthorize("@ss.hasPermi('system:tyre:list')")
    @GetMapping("/list")
    public TableDataInfo list(LuntaiUserTyre luntaiUserTyre)
    {
        startPage();
        List<LuntaiUserTyre> list = luntaiUserTyreService.selectLuntaiUserTyreList(luntaiUserTyre);
        return getDataTable(list);
    }

    /**
     * 查询tyre 用户轮胎信息列表，不分页
     */
    @PreAuthorize("@ss.hasPermi('system:tyre:list')")
    @GetMapping("/list2")
    public AjaxResult list2(LuntaiUserTyre luntaiUserTyre)
    {
        List<LuntaiUserTyre> list = luntaiUserTyreService.selectLuntaiUserTyreList(luntaiUserTyre);
        return AjaxResult.success(list);
    }

    /**
     * 查询tyre 用户轮胎信息列表,每个位置1个，最多四个
     */
    @PreAuthorize("@ss.hasPermi('system:tyre:list')")
    @GetMapping("/list3")
    public AjaxResult list3(LuntaiUserTyre luntaiUserTyre)
    {
        List<LuntaiUserTyre> list = luntaiUserTyreService.selectLuntaiUserTyreList3(luntaiUserTyre);
        return AjaxResult.success(list);
    }

    /**
     * 导出tyre 用户轮胎信息列表
     */
    @PreAuthorize("@ss.hasPermi('system:tyre:export')")
    @Log(title = "tyre 用户轮胎信息", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, LuntaiUserTyre luntaiUserTyre)
    {
        List<LuntaiUserTyre> list = luntaiUserTyreService.selectLuntaiUserTyreList(luntaiUserTyre);
        ExcelUtil<LuntaiUserTyre> util = new ExcelUtil<LuntaiUserTyre>(LuntaiUserTyre.class);
        util.exportExcel(response, list, "tyre 用户轮胎信息数据");
    }

    /**
     * 获取tyre 用户轮胎信息详细信息
     */
    @PreAuthorize("@ss.hasPermi('system:tyre:query')")
    @GetMapping(value = "/{id}")
    public AjaxResult getInfo(@PathVariable("id") Integer id)
    {
        return success(luntaiUserTyreService.selectLuntaiUserTyreById(id));
    }

    /**
     * 新增tyre 用户轮胎信息
     */
    @PreAuthorize("@ss.hasPermi('system:tyre:add')")
    @Log(title = "tyre 用户轮胎信息", businessType = BusinessType.INSERT)
    @PostMapping("/add")
    public AjaxResult add(@RequestBody LuntaiUserTyre luntaiUserTyre)
    {
        return toAjax(luntaiUserTyreService.insertLuntaiUserTyre(luntaiUserTyre));
    }

    /**
     * 修改tyre 用户轮胎信息
     */
    @PreAuthorize("@ss.hasPermi('system:tyre:edit')")
    @Log(title = "tyre 用户轮胎信息", businessType = BusinessType.UPDATE)
    @PutMapping("/edit")
    public AjaxResult edit(@RequestBody LuntaiUserTyre luntaiUserTyre)
    {
        return toAjax(luntaiUserTyreService.updateLuntaiUserTyre(luntaiUserTyre));
    }

    /**
     * 删除tyre 用户轮胎信息
     */
    @PreAuthorize("@ss.hasPermi('system:tyre:remove')")
    @Log(title = "tyre 用户轮胎信息", businessType = BusinessType.DELETE)
	@DeleteMapping("/{ids}")
    public AjaxResult remove(@PathVariable Integer[] ids)
    {
        return toAjax(luntaiUserTyreService.deleteLuntaiUserTyreByIds(ids));
    }
}
